/**
 * 
 */
package com.shine.icis.blo.imp;

import com.shine.cotrun.sql.QueryParameters;
import com.shine.cotrun.web.comm.ListPage;
import com.shine.icis.blo.IBusinessConfService;
import com.shine.icis.dao.IBusinessConfDAO;
import com.shine.icis.hbean.BusinessConf;

/**
 * @author zsy
 *
 */
public class BusinessConfService implements IBusinessConfService {
	
	private IBusinessConfDAO businessConfDAO;

	public void setBusinessConfDAO(IBusinessConfDAO businessConfDAO) {
		this.businessConfDAO = businessConfDAO;
	}
	
	@Override
	public BusinessConf getBusinessConfById(int id) {
		BusinessConf bc =  businessConfDAO.findById(id);
		return bc;
	}
	
	@Override
	public ListPage<BusinessConf> getBusinessConfPage(QueryParameters qp) {
		ListPage<BusinessConf> bcPage = businessConfDAO.findBusinessConfPage(qp);
		return bcPage;
	}

	@Override
	public void modifyBusinessConf(int busiId, String confValue,
			boolean enableFlag, String note) {
		if (confValue == null) {
			throw new IllegalArgumentException("置配值不能为空");
		}
		BusinessConf bc = businessConfDAO.findById(busiId);
		if (bc == null) {
			throw new IllegalArgumentException("记录不存在");
		}
		bc.setEnableFlag(enableFlag);
		bc.setConfValue(confValue);
		bc.setNote(note);
		businessConfDAO.update(bc);
	}
}
